<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
        }

        ul {
            width: 1200px;
            margin: auto;
            display: flex;
            flex-wrap: wrap;
        }

        li {
            width: 23%;
            margin: 1%;
            box-shadow: 0 0 1px 1px #ddd;
            text-align: center;
        }

        img {
            width: 100%;
            height: 300px;
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <img src="" alt="">
            <h3></h3>
            <p></p>
            <strong></strong>
        </li>
    </ul>


    <script src="../js/ajax.js"></script>
    <script>

        const oUl = document.querySelector('ul');

        ajax({
            path: '../php/goods_list.php',
            success: res => {
                console.log(res);
                const { status, msg, data } = res;
                if (status) {
                    let html = '';
                    data.forEach(v => {
                        const { goods_title, goods_des, goods_price, goods_img, goods_id } = v;
                        html += `
                            <li>
                                <a href="./04detail.html?id=${goods_id}">
                                <img src="${goods_img}" alt="">
                                <h3>${goods_title}</h3>
                                <p>${goods_des}</p>
                                <strong>${goods_price}</strong>
                                </a>
                            </li>
                        `
                    })
                    oUl.innerHTML = html;
                } else {
                    alert(msg);
                }
            }
        })

    </script>

</body>

</html>